#ifndef __HTTP_UTIL_H__
#define __HTTP_UTIL_H__
#include "cocos2d.h"
#include "cocos-ext.h"


namespace gofgame {
	namespace jumpdown {
		namespace util {
			class HttpUtil :public cocos2d::CCNode{
			public:
				static HttpUtil* shareHttpUtil();
				//void onHttpRequestCompleted(cocos2d::CCNode *sender, void *data) {
				//	CCHttpResponse *response = (CCHttpResponse*)data;

				//	if (!response)
				//	{
				//		return;
				//	}

				//	int statusCode = response->getResponseCode();
				//	char statusString[64] = {};
				//	sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
				//	CCLog("response code: %d", statusCode);

				//	if (!response->isSucceed()) 
				//	{
				//		CCLog("response failed");
				//		CCLog("error buffer: %s", response->getErrorBuffer());
				//		return;
				//	}

				//	// dump data
				//	std::vector<char> *buffer = response->getResponseData();
				//	printf("Http Test, dump data: ");
				//	for (unsigned int i = 0; i < buffer->size(); i++)
				//	{
				//		printf("%c", (*buffer)[i]);
				//	}
				//	printf("\n");
				//}
				void sendPost(std::string url,CCObject *target,cocos2d::SEL_CallFuncND pSelector);
				void sendPost(std::string url,std::string data,cocos2d::SEL_CallFuncND pSelector);
				void sendGet(std::string url,cocos2d::SEL_CallFuncND pSelector);
			private:
				 void onHttpRequestCompleted(cocos2d::CCNode *sender, void *data);
			};
		}
	}
}

#endif //__HTTP_UTIL_H__
